package com.quectel.sdk.baidu;

import com.quectel.sdk.ex.hikisc.HikFactoryErrorException;

/**
 * 在这里编写说明
 *
 * @author: nolan.zhang
 * @email: nolan.zhang@quectel.com
 * @date: 2023-05-11 11:01:00
 */
public class BaiduBCEClientBuilder {

    /**
     * host
     */
    private String host;
    /**
     * API Key
     */
    private String apikey;
    /**
     * Secret Key
     */
    private String secretKey;


    private BaiduBCEClientBuilder() {
    }

    public static BaiduBCEClientBuilder builder() {
        return new BaiduBCEClientBuilder();
    }

    public BaiduBCEClientBuilder host(String host) {
        this.host = host;
        return this;
    }

    public BaiduBCEClientBuilder apikey(String apikey) {
        this.apikey = apikey;
        return this;
    }

    public BaiduBCEClientBuilder secretKey(String secretKey) {
        this.secretKey = secretKey;
        return this;
    }

    public <T extends AbstractBaiduBCEBaseClient> T build(Class<T> executorCls) {
        if (host == null || apikey == null || apikey == null) {
            throw new HikFactoryErrorException("Missing request parameter.");
        }
        try {
            T t = executorCls.newInstance();
            t.setRequester(BaiduBCERequester.getInstance(host, apikey, secretKey));
            return t;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
